package com.woniu.adopt.mapper;

import com.woniu.adopt.entity.Role;
import com.woniu.adopt.vo.RecycleVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Role record);

    Role selectByPrimaryKey(int id);

    List<Role> selectAll();

    int updateByPrimaryKey(Role record);

    List<Role> selectRoleByName(String name);

    @Delete("delete from t_manager_role where role_id = #{id}")
    void deleteManagerRoleByRoleId(Long id);

    @Delete("delete from t_role_permission where role_id = #{id}")
    void deleteRolePermissionByRoleId(long id);

    void insertPermissionByRole(@Param("roleId") int id, @Param("perArr") int[] perCheckedIds);

    List<Role> selectRoleByManagerId(int id);

    //查询所有的被删系统信息
    List<RecycleVo> selectRecycle();

    @Update("update t_role set del=0,update_time=now() where id=#{value}")
    int doRecycle(int id);
}